﻿namespace Huayou.Utils
{
    using System;

    public class DateUtils
    {
        public static string DateFormat()
        {
            return DateFormat(DateTime.Now);
        }

        public static string DateFormat(DateTime date)
        {
            return DateFormat(date, "yyyy-MM-dd");
        }

        public static string DateFormat(string date)
        {
            return DateFormat(Convert.ToDateTime(date));
        }

        public static string DateFormat(DateTime date, string format)
        {
            return date.ToString(format);
        }

        public static string DateFormat(string date, string format)
        {
            return DateFormat(Convert.ToDateTime(date), format);
        }

        public static string DateTimeFormat(DateTime datetime)
        {
            return DateTimeFormat(datetime, "yyyy-MM-dd HH:mm");
        }

        public static string DateTimeFormat(DateTime datetime, string format)
        {
            return datetime.ToString(format);
        }

        public static int DiffYear(DateTime start)
        {
            return DiffYear(start, DateTime.Now);
        }

        public static int DiffYear(string start)
        {
            return DiffYear(Convert.ToDateTime(start));
        }

        public static int DiffYear(DateTime start, DateTime end)
        {
            return (end.Year - start.Year);
        }

        public static int DiffYear(string start, string end)
        {
            return DiffYear(Convert.ToDateTime(start), Convert.ToDateTime(end));
        }
    }
}

